package com.fr.report.semantic;

import com.fr.base.ColumnRow;
import com.fr.base.Style;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.CellElement;
import com.fr.report.DefaultCellElement;
import com.fr.report.TemplateReport;
import com.fr.report.painter.BiasTextPainter;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class CrossWizardRpt extends AbstractWizardRpt
{
  private List columnWizardCellList = new ArrayList();
  private List rowWizardCellList = new ArrayList();
  private List summaryWizardCellList = new ArrayList();

  public void insertIntoReport(TemplateReport paramTemplateReport, ColumnRow paramColumnRow)
  {
    WizardCellElement localWizardCellElement;
    int i2;
    if (paramTemplateReport == null)
      return;
    int i = paramColumnRow.getColumn();
    int j = paramColumnRow.getRow();
    StringBuffer localStringBuffer = new StringBuffer();
    for (int k = 0; k < this.columnWizardCellList.size(); ++k)
    {
      localWizardCellElement = (WizardCellElement)this.columnWizardCellList.get(k);
      if (localStringBuffer.length() != 0)
        localStringBuffer.append("|");
      localStringBuffer.append(localWizardCellElement.getColumnName());
      addWCelllElementCondition(paramTemplateReport, localWizardCellElement);
      localObject = localWizardCellElement.toCellElement(this.rowWizardCellList.size() + i, k + j, 1);
      paramTemplateReport.addCellElement((CellElement)localObject);
      i1 = Math.max(paramTemplateReport.getColumnWidth(((CellElement)localObject).getColumn()), localWizardCellElement.getColumnWidth());
      paramTemplateReport.setColumnWidth(((CellElement)localObject).getColumn(), i1);
      i2 = Math.max(paramTemplateReport.getRowHeight(((CellElement)localObject).getRow()), localWizardCellElement.getRowHeight());
      paramTemplateReport.setRowHeight(((CellElement)localObject).getRow(), i2);
    }
    for (k = 0; k < this.rowWizardCellList.size(); ++k)
    {
      localWizardCellElement = (WizardCellElement)this.rowWizardCellList.get(k);
      if (localStringBuffer.length() != 0)
        localStringBuffer.append("|");
      localStringBuffer.append(localWizardCellElement.getColumnName());
      addWCelllElementCondition(paramTemplateReport, localWizardCellElement);
      localObject = localWizardCellElement.toCellElement(k + i, this.columnWizardCellList.size() + j, 1, this.summaryWizardCellList.size(), 0);
      paramTemplateReport.addCellElement((CellElement)localObject);
      i1 = Math.max(paramTemplateReport.getColumnWidth(((CellElement)localObject).getColumn()), localWizardCellElement.getColumnWidth());
      paramTemplateReport.setColumnWidth(((CellElement)localObject).getColumn(), i1);
      i2 = Math.max(paramTemplateReport.getRowHeight(((CellElement)localObject).getRow()), localWizardCellElement.getRowHeight());
      paramTemplateReport.setRowHeight(((CellElement)localObject).getRow(), i2);
    }
    for (k = 0; k < this.summaryWizardCellList.size(); ++k)
    {
      localWizardCellElement = (WizardCellElement)this.summaryWizardCellList.get(k);
      addWCelllElementCondition(paramTemplateReport, localWizardCellElement);
      localObject = localWizardCellElement.toCellElement(this.rowWizardCellList.size() + i, this.columnWizardCellList.size() + k + j, 2);
      paramTemplateReport.addCellElement((CellElement)localObject);
      i1 = Math.max(paramTemplateReport.getColumnWidth(((CellElement)localObject).getColumn()), localWizardCellElement.getColumnWidth());
      paramTemplateReport.setColumnWidth(((CellElement)localObject).getColumn(), i1);
      i2 = Math.max(paramTemplateReport.getRowHeight(((CellElement)localObject).getRow()), localWizardCellElement.getRowHeight());
      paramTemplateReport.setRowHeight(((CellElement)localObject).getRow(), i2);
    }
    BiasTextPainter localBiasTextPainter = new BiasTextPainter(localStringBuffer.toString());
    localBiasTextPainter.setIsBackSlash(false);
    Object localObject = new DefaultCellElement(i, j, this.rowWizardCellList.size(), this.columnWizardCellList.size(), localBiasTextPainter);
    paramTemplateReport.addCellElement((CellElement)localObject);
    int l = Math.max(paramTemplateReport.getColumnWidth(((CellElement)localObject).getColumn()), 100);
    paramTemplateReport.setColumnWidth(((CellElement)localObject).getColumn(), l);
    int i1 = Math.max(paramTemplateReport.getRowHeight(((CellElement)localObject).getRow()), 30);
    paramTemplateReport.setRowHeight(((CellElement)localObject).getRow(), i1);
    Iterator localIterator = paramTemplateReport.cellIterator();
    while (true)
    {
      do
      {
        if (!(localIterator.hasNext()))
          return;
        localObject = (CellElement)localIterator.next();
      }
      while (localObject == null);
      Style localStyle = ((CellElement)localObject).getStyle();
      ((CellElement)localObject).setStyle(localStyle.deriveBorder(1, Color.black, 1, Color.black, 1, Color.black, 1, Color.black));
    }
  }

  public void addColumnWizardCell(WizardCellElement paramWizardCellElement)
  {
    this.columnWizardCellList.add(paramWizardCellElement);
  }

  public int getColumnWizardCellCount()
  {
    return this.columnWizardCellList.size();
  }

  public WizardCellElement getColumnWizaredCell(int paramInt)
  {
    return ((WizardCellElement)this.columnWizardCellList.get(paramInt));
  }

  public void clearColumnWizardCell()
  {
    this.columnWizardCellList.clear();
  }

  public void addRowWizardCell(WizardCellElement paramWizardCellElement)
  {
    this.rowWizardCellList.add(paramWizardCellElement);
  }

  public int getRowWizardCellCount()
  {
    return this.rowWizardCellList.size();
  }

  public WizardCellElement getRowWizaredCell(int paramInt)
  {
    return ((WizardCellElement)this.rowWizardCellList.get(paramInt));
  }

  public void clearRowWizardCell()
  {
    this.rowWizardCellList.clear();
  }

  public void addSummaryWizardCell(WizardCellElement paramWizardCellElement)
  {
    this.summaryWizardCellList.add(paramWizardCellElement);
  }

  public int getSummaryWizardCellCount()
  {
    return this.summaryWizardCellList.size();
  }

  public WizardCellElement getSummaryWizaredCell(int paramInt)
  {
    return ((WizardCellElement)this.summaryWizardCellList.get(paramInt));
  }

  public void clearSummaryWizardCell()
  {
    this.summaryWizardCellList.clear();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isAttr())
    {
      clearColumnWizardCell();
      clearRowWizardCell();
      clearSummaryWizardCell();
    }
    if (paramXMLableReader.isChildNode())
    {
      WizardCellElement localWizardCellElement;
      String str = paramXMLableReader.getTagName();
      if ("RowWizardCellElement".equals(str))
      {
        localWizardCellElement = new WizardCellElement();
        paramXMLableReader.readXMLObject(localWizardCellElement);
        this.rowWizardCellList.add(localWizardCellElement);
      }
      else if ("ColumnWizardCellElement".equals(str))
      {
        localWizardCellElement = new WizardCellElement();
        paramXMLableReader.readXMLObject(localWizardCellElement);
        this.columnWizardCellList.add(localWizardCellElement);
      }
      else if ("SummaryWizardCellElement".equals(str))
      {
        localWizardCellElement = new WizardCellElement();
        paramXMLableReader.readXMLObject(localWizardCellElement);
        this.summaryWizardCellList.add(localWizardCellElement);
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    WizardCellElement localWizardCellElement;
    super.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.startTAG("CrossWizardRpt");
    int i = 0;
    int j = this.rowWizardCellList.size();
    while (i < j)
    {
      localWizardCellElement = (WizardCellElement)this.rowWizardCellList.get(i);
      paramXMLPrintWriter.startTAG("RowWizardCellElement");
      localWizardCellElement.writeXML(paramXMLPrintWriter);
      paramXMLPrintWriter.end();
      ++i;
    }
    i = 0;
    j = this.columnWizardCellList.size();
    while (i < j)
    {
      localWizardCellElement = (WizardCellElement)this.columnWizardCellList.get(i);
      paramXMLPrintWriter.startTAG("ColumnWizardCellElement");
      localWizardCellElement.writeXML(paramXMLPrintWriter);
      paramXMLPrintWriter.end();
      ++i;
    }
    i = 0;
    j = this.summaryWizardCellList.size();
    while (i < j)
    {
      localWizardCellElement = (WizardCellElement)this.summaryWizardCellList.get(i);
      paramXMLPrintWriter.startTAG("SummaryWizardCellElement");
      localWizardCellElement.writeXML(paramXMLPrintWriter);
      paramXMLPrintWriter.end();
      ++i;
    }
    paramXMLPrintWriter.end();
  }
}